<template>
	<view class="warp">
		<view class="header-image">
			<view class="image-box">
				<image :src="userImg" mode="widthFix"></image>
			</view>
			<view class="btns">
				<button size="mini" @click="clickGZ" style="background-color: #DF851D;" v-if="!show">+ 关注</button>
				<button size="mini" @click="clickGZ" style="background-color: #666666;" v-else>+ 已关注</button>
				<button size="mini" open-type="share">分享</button>
			</view>
		</view>
		<view class="header-content">
			<text>{{Name}}</text>
			<view class="text-box">
				<view class="text-left">
					<text class="num">{{Num}}</text><text class="content">粉丝</text>
				</view>
				<view class="text-middle">

				</view>
				<view class="text-right">
					<text v-if="count == null" class="num">0</text>
					<text v-else class="num">{{count}}万</text>
					<text class="content">获赞</text>
				</view>
			</view>
		</view>
		<view class="">
			{{Name}}的视频
		</view>
		<view class="selectBox">
			<view class="selectItem" v-for="(el,index) in classList" :key="index" @click="goDetails(el)">
				<image class="selectImg" :src="el.cover_img" mode=""></image>
				<view class="selectText">
					{{el.title}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getUserDetail,
		getuserFans,
		getaddPlay,
		getSmallTheaterDetails
	} from '@/module/index.js'
	export default {
		data() {
			return {
				show: false,
				id: "",
				classList: [],
				Name: "",
				Num: 0,
				count: 0,
				userImg: "",
				admin_id: "",
				video_id: "",
				videoName: "",
				coverImg: ""
			}
		},
		onShow() {
			this.getUserDetail(this.id)
		},
		onLoad(option) {
			this.id = option.id
			this.video_id = option.video_id
		},
		methods: {
			clickGZ() {
				this.show = !this.show
				console.log(this.show)
				if (this.show == false) {
					this.getuserFans(2)
				} else {
					this.getuserFans(1)
				}
			},
			getuserFans(type) {
				let obj = {
					admin_id: this.admin_id,
					type: type
				}
				//发起请求
				getuserFans(obj).then((res) => {
					if (res.code === 200) {
						console.log(res)
					} else {
						uni.showToast({
							title: `操作失败`,
							icon: "none"
						})
					}
				}).catch(err => {
					console.log(err)
				})
			},
			// 获取视频主信息
			getUserDetail(id) {
				let obj = {
					admin_id: id
				}
				//发起请求
				getUserDetail(obj).then((res) => {
					if (res.code === 200) {
						console.log(res)
						this.classList = res.data.data[0].videoItem
						this.Name = res.data.data[0].name
						this.Num = res.data.data[0].fans_count
						this.count = res.data.count.give_count
						this.userImg = res.data.data[0].profile_photo
						this.show = res.data.concern
						this.admin_id = res.data.data[0].id
					} else {
						uni.showToast({
							title: res.message,
							icon: "none"
						})
					}
				}).catch(err => {
					console.log(err)
				})
			},
			goDetails(el) {
				uni.navigateTo({
					url: `/wxcomponents/lifeRecommend/yjy-video-slide/yjy-video-slide?video_id=` + el.id
				});
			},

		}
	}
</script>

<style scoped lang="scss">
	.warp {
		padding: 0px 12rpx;
	}

	.header-image {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.image-box {
		width: 100rpx;
		height: 100rpx;
		overflow: hidden;
		border-radius: 50%;
		margin-bottom: 12rpx;
	}

	image {
		width: 100%;
		height: 100%;
	}

	button {
		display: inline-block;
		background-color: #4CD964;
		color: #FFFFFF;
		margin: 0rpx 20rpx;
		border-radius: 16rpx;
	}

	.title {
		margin: 8rpx 0rpx;
		font-size: 26rpx;
		color: #666666;
	}

	.text-box {
		display: flex;
		align-items: center;
	}

	.text-middle {
		width: 1px;
		height: 26rpx;
		background-color: #999999;
		margin: 0px 12rpx;
	}

	.num {
		font-weight: bold;
		font-size: 26rpx;
		margin-right: 8rpx;
	}

	.content {
		font-size: 26rpx;
		font-weight: 300;
	}

	.header-content {
		margin-bottom: 20rpx;
	}

	.selectBox {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-around;
		align-items: center;

		.selectItem {
			width: 42%;
			margin: 8rpx 12rpx;
			border-radius: 8rpx;
			border: 1px solid #CBC9C5;
		}

		.selectImg {
			width: 100%;
			height: 500rpx;
		}

		.selectText {
			font-weight: bold;
			font-size: 28rpx;
			text-align: center;
		}
	}

	.selectBox:after {
		display: block;
		content: "";
		width: 42%;
		height: 0px;
	}
</style>
